import cv2
def show_img(window_name, img, delay):
    cv2.imshow(window_name, img)
    cv2.waitKey(delay)
    cv2.destroyAllWindows()

img=cv2.imread('C:\puppy.jpg')
if img is not None and len(img.shape)==3:
    print('img.shape:',img.shape)
    show_img('img',img,-1)
    if img.shape[2]==3:
        b,g,r=cv2.split(img)
        show_img('b',b,-1)
        show_img('g',g,-1)
        show_img('r',r,-1)
    elif img.shape[2]==4:
        b,g,r,a=cv2.split(img)
        show_img('b', b, -1)
        show_img('g', g, -1)
        show_img('r', r, -1)
        show_img('a',a,-1)
        m = cv2.merge([b, g, r])